Dear JS Enthusiasts,
What is the best way to pack a JS file as much as possible using PHP?
Links would be appreciated.
Thanks
Dear JS Enthusiasts,
What is the best way to pack a JS file as much as possible using PHP?
Links would be appreciated.
Thanks
To "pack a JS" file? What exactly do you mean by that?
- Mike
the only way i could think of is to take out all unneccessary returns
The only person I think is cool is -==INSERT YOUR NAME HERE==-
Do you mean pack (compress its size)? Do you mean using PHP to do this or do you mean so that it takes up less space as an include or whatever? Javascript can be made to take up less space if variable and function names are shortened and unnecessary line breaks and punctuation are removed. Code can often be reduced more by reusing code that appears more than once and using ? : tests instead of if else tests.
It is usually not worth it to do this unless bandwidth is very low. The resulting file will be hard to read and edit.
One good practice with javascript is to keep scripts external and link them to the various pages using them (if more than one) via an external script tag (instead of an include or any other method). That way each script only needs to be cached once.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Bookmarks