Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
javascript load just before body end tag in DOM
![jackmaessen](https://us.v-cdn.net/5018160/uploads/userpics/801/nBTGG26FI2OYC.png)
how can i load a javascript just before the body end tag ?
I am developing a new plugin in which a javascript should be loaded just before the body end tag
<script src="/plugins/Headroom/js/headroom2.js"></script>
I can do it manually by adding this into the default.master.tpl of the theme, but is this also possible without manually adding it?
0
Comments
Make a plugin to add the script or add it to theme hooks . on load it the variable possibly look at jquery docs
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
But which fire-event should i use so that is loaded just before the endtag body?
Why do you want this priority? You can set priority with
AddScript
but I have to question why this is necessary with one script.What are you trying to do? Show us the code.
grep is your friend.
Use base_afterBody_handler(): https://github.com/vanilla/vanilla/blob/master/applications/dashboard/views/default.master.tpl#L42
It might not work for custom themes...
If you can try adding it like this. Create a plugin to add the script. Make a file and call it something myscript.js and add this jquery bellow code to that file and save it in the new plugin folder. Then create the plugin default.php and have it load the the script.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Thanks guys (@x00 @R_J @vrijvlinder )for the support. I did already find a solution for it.
It was all about a javascript that should be at the end of the DOM and called immediately.
While i was thinkig about this, i thought: why not put it in the ready handler and load this script into the head tags?
That's what i did:
It was all about this plugin: http://vanillaforums.org/addon/headroom-plugin
although
querySelector
is well supported you might as well use$("#header")[0]
that is how would get the native DOM element from the jquery object.grep is your friend.