[wp-hackers] Using wp-content/uploads to store dynamically created js and CSS

Nicola Peluchetti nicola.peluchetti at gmail.com
Wed Jan 8 20:39:09 UTC 2014


Hi,

our plugin at the moment generates CSS and Javascript files in PHP. This
means that we append a link /script to the website and then a PHP script
generates the relevant CSS/js.

We need to do this with CSS because we generate it from LESS files and give
the user the ability to modify variables, we do this with Javascript
because we use requirejs and we wanted to avoid using global variables in
javascript, so we create modules dinamically and build things on the fly.

We had a fallback system for storing CSS ( APC/Filesystem/DB ) while js was
just read.

In any case this has proven to be too slow and unreliable, so we'd like to
go back serving static css and js files and we thought we can use
wp-content/upload to store compilade .js and .css files.

I've read this article
http://ottopress.com/2011/tutorial-using-the-wp_filesystem/ where Otto says
to inline, but if i inline my js / css is not cached by the browser
right?And we are talking about 500kb so it's not trivial.

What do you think of the approach and have you got anything better to
suggest?


*Nicola Peluchetti - Senior PHP Developer @ Timely*
Twitter: @nik_peluchetti <https://twitter.com/#!/nik_peluchetti>
Facebook: nicola.peluchetti <https://www.facebook.com/nicola.peluchetti>
Stackoverflow: Stackoverflow<http://stackoverflow.com/users/397861/nicola-peluchetti>
Mobile: +39 339 7507235


More information about the wp-hackers mailing list