[ABD] Custom Code

Any abandoned Extensions will be moved to this forum.

WARNING: Extensions in this forum are not currently being supported or maintained by the original Extension author. Proceed at your own risk.
Forum rules
IMPORTANT: Extension Development Forum rules

WARNING: Extensions in this forum are not currently being supported nor updated by the original Extension author. Proceed at your own risk.
Locked
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

I'm wondering if I could use this extension to defer JS in the extensions I have. Would the code go in overall_header_body_before? Please read here: viewtopic.php?p=14399621#p14399621

If this would work would my code look like this:

Code: Select all

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "defer.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>
</body>
</html>
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

John connor wrote:I'm wondering if I could use this extension to defer JS in the extensions I have. Would the code go in overall_header_body_before? Please read here: viewtopic.php?p=14399621#p14399621

If this would work would my code look like this:

Code: Select all

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "defer.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>
</body>
</html>
This extension does not work since phpBB 3.1.6. See the first post of this topic.
Also, put all your Javascript at the end of the page.
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

Yes, I use insertemplate. Have since 3.1.6. The JS files I would like to defer are from extensions.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

John connor wrote:Yes, I use insertemplate. Have since 3.1.6. The JS files I would like to defer are from extensions.
I've no other answer than what was already given to you in viewtopic.php?p=14399621#p14399496
Mick wrote:You should be asking in extension writers or wherever you got the code from.
Also, you can check if the cache headers are set for your Javascript files.
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

I don't understand why they're saying that in my other post. I go here: https://varvy.com/pagespeed/ and this is what it says:


http://i.imgur.com/yrJYvP5.jpg

http://i.imgur.com/JCab2hz.jpg

The website recommends that I defer my JS files. If that HTML code could be converted to PHP then perhaps I would add it to the bottom of index.php?

I was told to clarify my question at Stack Exchange as well. I can defer JS in Wordpress!

BTW, I run an anti-hacker script so I have to temp disable it otherwise this won't work at the page speed site. So don't no one try this with my site. It more than likely won't work.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

John connor wrote:I don't understand why they're saying that in my other post. I go here: https://varvy.com/pagespeed/ and this is what it says:


http://i.imgur.com/yrJYvP5.jpg

http://i.imgur.com/JCab2hz.jpg

The website recommends that I defer my JS files. If that HTML code could be converted to PHP then perhaps I would add it to the bottom of index.php?

I was told to clarify my question at Stack Exchange as well. I can defer JS in Wordpress!

BTW, I run an anti-hacker script so I have to temp disable it otherwise this won't work at the page speed site. So don't no one try this with my site. It more than likely won't work.
The screendump you give says there are many Javascript files. Not that they need to be deferred.
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

It would be nice to defer the scripts that website shows though. I've done this in WordPress. There must be a way to do this is phpBB.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

John connor wrote:It would be nice to defer the scripts that website shows though. I've done this in WordPress. There must be a way to do this is phpBB.


The Javascript should already be at the end.

The site suggests to put together the javascript code in one file, called defer.js. This will not be possible in phpBB without doing ugly things.

Btw. the code you gave is mostly the same as:

Code: Select all

<script src="defer.js" defer></script>
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

No. That is NOT correct. Read here: https://varvy.com/pagespeed/
3. Change the "defer.js" to the name of your external JS file.
I should be able to do this:

Code: Select all

<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "https://systechforum.net/ext/paybas/breadcrumbmenu/styles/all/template/breadcrumb-menu.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>

But if you read that link....it's to be placed in a HTML document.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: [RC] Custom Code

Post by GoBieN »

Of course it should, Javascript is part of HTML pages.

You can use the inserttemplates (see 1st post of this topic) extension to add the Javascript code at event below footer or something like that, which would insert the Javascript code in the HTML at the bottom of the page.

But if you want to do this for all javascript files from phpBB and extensions then you will have lots of work and it probably won't be worth it.
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

Yeah, I tried adding the defer script to one of the headers and cleared the cache for each test, but it didn't look like the scripts were deferred.

I have been using customcode and inserttemplate for a year just to let you know.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: [RC] Custom Code

Post by GoBieN »

Customcode doesn't work on 3.1.8 anymore, but if you have used to as you say, you should have no trouble doing the things you want.
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

I know it doesn't I have been using inserttemplate since custom code no longer worked.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
TriKe27
Registered User
Posts: 18
Joined: Wed Feb 25, 2015 6:30 pm

Re: [RC] Custom Code

Post by TriKe27 »

Hi martti,

will there be an update for this extensions that it will work with phpBB >3.1.6? I would love to use it in the future (without workarounds etc.).

Greetings
Martin
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

TriKe27 wrote:Hi martti,

will there be an update for this extensions that it will work with phpBB >3.1.6? I would love to use it in the future (without workarounds etc.).

Greetings
Martin
No, there won't be.
Locked

Return to “Abandoned Extensions”