Selectively Loading Javascript files by page?
-
Until now, I’ve enqueued the scripts or CSS I want to use in my functions.php. But to make the pages ‘lighter’ I’m wondering if there is a fairly elegant way to selectively load JS scripts based on -page-id or template?
For example, if I have a shopping cart, I want a way to control the loading of that script only on specific pages… but -still- use the enqueue function.
Yeah, I can go into the header and make ‘if/else’ statements, but that doesn’t seem ‘right’ somehow.
In short: is there a plug-in or API which allows me to specify which scripts will be loaded based on page-id or template?
TIA,
—JC
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘Selectively Loading Javascript files by page?’ is closed to new replies.