Asset Helper brings Rails-style asset helper functions to WordPress. The provided functions are:
stylesheet_tag()
javascript_tag()
image_tag()
At their most basic, these functions create the appropriate HTML tags for the supplied arguments. The benefit comes from the additional features of these functions: timestamping and asset hosts.
Timestamping
Each resulting HTML tag will include a Unix timestamp representing the last-modified time of the file. For example:
This allows you to set a far-future expires time for your static files while ensuring that if these files
do change, browsers will always get the updated version, while keeping them cached otherwise.
Asset Hosts
This plugin also allows for static file hosts. If you have one defined, the resulting HTML tags will include complete URLs pointing to the files on your static file server. For example:
To define a static asset host, place the following line in
wp-config.php
:
define('ASSET_HOST', '
static.example.com');
Don't worry about including "http://" or "https://" -- The plugin will automatically use whichever one is used for the page the functions appear on.