@alriksson You can do it via custom JS. Write a script that will fire DOMContentLoaded and delay the same script using Flying Scripts. Make sure that the script is at the bottom. https://stackoverflow.com/questions/9153314/manually-dispatchevent-domcontentloaded
I haven’t tried it. It should work.
Thread Starter
Rookie
(@alriksson)
@gijo Thanks for the suggestion. I tried different variations but only make it work once user click. Then it trigger the DOMContentLoaded and load all things using this one. Would like it just to trigger once it’s loaded if possible.
But it also seem to cause issue with other things, such as with oxygen page builders navigation. Which uses inline jQuery to open and fold the drop down menu. It open after page loaded and act strange.
It seems like the DOMContentLoaded trigger open them on every mouse click etc. So it conflict there. Maybe possible to trigger without click and target it towards a specific file that contains the words “this-javascript”.
Blow is the snippet that stop working once I delay the script with flying scripts.
document.addEventListener("DOMContentLoaded", (function() {
for (var t = document.querySelectorAll(".glsr"), i = 0; i < t.length; i++) {
var n = window.getComputedStyle(t[i], null).getPropertyValue("direction");
t[i].classList.add("glsr-" + n)
}
window.GLSR.Forms = S,
new S,
new y,
new a
}
))
}
-
This reply was modified 5 years, 7 months ago by
Rookie.
-
This reply was modified 5 years, 7 months ago by
Rookie.
-
This reply was modified 5 years, 7 months ago by
Rookie.
Thread Starter
Rookie
(@alriksson)
Any ideas or suggestions is very much appriciated.
Sometimes it seems to work and sometimes not. The script execute but doesn’t always properly load above snippet. Making it fail more often than it sucess.
Used this one for better debugging.
// Code goes here
document.addEventListener('DOMContentLoaded', (event) => {
console.log('DOMContentLoaded triggered');
});
const event = new Event('DOMContentLoaded', {
view: window,
bubbles: true,
cancelable: true
});
const cancelled = !document.dispatchEvent(event);
if (cancelled) {
// A handler called preventDefault.
console.log('The event was cancelled...');
} else {
// None of the handlers called preventDefault.
console.log('The event was not cancelled...');
}
Hello,
I have this error in flying scripts 🙁
how can i solve this problem https://generatepress.com/forums/topic/twice-click/#post-1560253