Secondly, during the bundling process (and this is, admittedly, crude) check the asset's file name and if it doesn't include the universal ".min." tag, minify the file using one of the myriad of open-source minify algorithms available on github.Īnd finally, return the HTML stylesheet or script tag linking to the new bundle file. Too easy, right? Fortunately, creating an "AssetPacker" class isn't as complicated as it may initially appear.įirstly, you need to use PHP to read the files on your server, load them into memory and then write them sequentially into a new bundle file on the server. When a page renders, the outcome of this pattern would look something like this: In my opinion, a neat, on-the-fly, pattern for Asset Packaging looks like this: ![]() You just want to minify and combine your files, darn-it!!!! You want to avoid installing multiple command line tools and configuring a comprehensive publishing pipeline for your simple, little PHP website. Also, quite complicated and offer a 100+ features that you probably don't yet need. ![]() The top-tier tools are incredibly efficient, reliable and well tested. js files.Ī web search will yield an enormous list of JavaScript and StyleSheet minifiers, compressors, bundlers and packagers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |