Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Function : js_push_if_not_exists()

Blair2004 edited this page Nov 12, 2014 · 6 revisions

Description : enqueue JavaScript file to the global JavaScript queue if this file hasn't yet been included. It a clever way to add js script once. This function check if a file path has already been recorded, if so, the file is not included. Files will been loaded in order of they are called. This function should also been used only on theme files.

Example :

    js_push_if_not_exists( theme_assets_url( '/js/jquery.js' ) ); /* First to load */   
    js_push_if_not_exists( theme_assets_url( '/js/custom.js' ) ); /* second and so on */