![]() ![]() This also has the benefit that every time you save any file while still developing it, you don’t have to take care of the cache, your browser will always load the latest file. The wpenqueuescript () function doesn’t support async/defer by itself, but luckily the scriptloadertag hook allows us to manipulate the wpenqueuescript () output really easily. The wpenqueuescript function itself is pretty straight forward, so let's take a look it's structure. You're usually going to use it in your functions.php file. '/js/custom-script.js' ) wpenqueuescript ( 'custom-script' ) Should simply be: wpenqueuescript ( 'custom-script', gettemplatedirectoryuri(). The wpenqueuescript function is what loads scripts into you WordPress site. Nowadays I usually use the latest apporach. This: wpregisterscript ( 'custom-script', gettemplatedirectoryuri(). But then you have to update all these string (for all files) manually and it’s easy to forget one, which will result in the browser loading old files from it’s cache. In the past, I have used the first or third option.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |