sega — 2012-11-19T18:28:18-05:00 — #1
I am not entirely sure if this is the right section to post this up on the forum.
Basically I have a web template I've created but as I've used a wide variate of script I wish to compress them, including both CSS and JS preferably into a single file. What is the easier was to go about web compression outside a content management system.
ralphm — 2012-11-19T19:00:45-05:00 — #2
vsdan — 2012-11-21T02:15:46-05:00 — #3
I assume you mean combine CSS and JS into respective single files since cannot combine CSS and JS into a single file.
oddz — 2012-11-26T11:38:41-05:00 — #4
Are there different assets delegated to separate pages or are all the assets included on every page request?
If all the assets are included on every page you could write script to crawl the page and write the css and js to a single file. Than you might be able to copy and paste that into a compressor and save to a separate file. Though for ease of maintenance it is probably best to use a helper library such as; assetic or build something similar in whatever application language you are using.
Of course, this becomes much more difficult and involved if different scripts are delegated on a page by page basis.
picnictutorials — 2012-11-26T13:10:45-05:00 — #5
I just did this to my site. Just copy and paste them all into two files. One for css and one for js. Keep them in the same order they currently are called in your working page. Don't erase any of the original files until you've tested that all is working.
sega — 2012-11-26T13:40:17-05:00 — #6
Thanks guys for your feedback.
I thought of your method @PicnicTutorials; which would do what I want. The only issue is there would still be white spacing in the file.
It's for a fully featured theme so it would make sense to include them on all the pages. Currently they are included on all the pages. Thanks for the link, this would prove useful in this theme. Not sure if you can have this on the WordPress installation. My original intention is to have a single CSS and a single JS file which would run all the scripts on the website. I feel if I was to run assestic it would automatically give me the minify version of each.
The only trouble is some scripts are needed before the header and other before the body, so I would be a little puzzled on wether two files would be needed to make sure everything runs as it shou;d.
picnictutorials — 2012-11-26T14:03:10-05:00 — #7
oddz — 2012-11-26T14:45:23-05:00 — #8
Doesn't the WordPress SEO plugin aggregate asset files?
sega — 2012-12-05T14:35:49-05:00 — #9
It's more for maintanability. With CSS I can have @import and place all the CSS together, which is okay, but when it comes down to the scripts, there is nothing much I can do, unless I go down the PHP path. For the WordPress version I will keep things in different files, as they can easily fix this on the WP file. I personally use W3TC for WordPress and it does an amazing job!
sega — 2012-12-05T15:23:23-05:00 — #10
I just came across this - http://headjs.com/, I will play around with this a little to see what makes of it.
eastcoast — 2012-12-05T17:54:19-05:00 — #11
Why not just use mod_deflate and make it functional on all text based files?
sega — 2012-12-06T09:27:03-05:00 — #12
I have solved my issue now. With the CSS I use a single file and within this file have a dozen or so imports to the various CSS files. For the scripts I now use head.js.