Welcome to Geeklog, Anonymous Thursday, October 06 2022 @ 08:43 pm EDT

Geeklog Forums

Where is the best place to include javascript files


I'm trying to use a javascript file for one of my blocks.
I don't know where to put the html statements for include this JS file.

- If I put in the "lib-custom" file, I'll get the "cannot modufy header" error.

- If I put in my theme template, this block will work only when using my theme.

any suggestion or idea please ?

Status: offline


Site Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Script tags can be used anywhere in an HTML document, so unless it's something that you want to use multiple times but only load once, you could put it directly into your block.

Otherwise, use the function CUSTOM_templatesetvars in lib-custom.php to define your own header variable that contains your JavaScript code.

bye, Dirk


Thaks for your reply !

I've finally include my script in my block.

but at the start of my reflexion, I thought to include a script file with custom function for many of my blocks. So I search a "generic place" like a custom_functions.js to use.
If I understand what you said, I think that CUSTOM_templatesetvars will give me this ability ! Smile

Many thanks Dirk

All times are EDT. The time is now 08:43 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content