We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

change javscript | Forum

ben
ben Apr 21 '14
Hello, how to change javascript

<script
type="text/javascript"src="small.js"></script>
to

<script async src="my.js">

i look at css, and i cant find it
thanks
The Forum post is edited by ben Apr 21 '14
Kяuncн Leader
Kяuncн Apr 29 '14
<script async src="/my.js"></script>
or for a more effeciant page load...
<script defer src="/my.js"></script>

Maybe I'm not understanding the question..
The Forum post is edited by Kяuncн Apr 29 '14
ben
ben Apr 30 '14
I test it using pagespeed, google told  that i have render bocking javascript in above the fold.

http://developers.google.com/speed/pagespeed/insights/

they suggest to change javascript code name to remove render blocking javascript

where oxwall put their javascipt? maybe in here but im not sure

        // ONLOAD JS
        $jsData .= '<script type="text/javascript">' . PHP_EOL . '$(function () {' . PHP_EOL;

        ksort($this->onloadJavaScript['items']);

        foreach ( $this->onloadJavaScript['items'] as $priority => $scripts )
        {
            foreach ( $scripts as $script )
            {
                $jsData .= '(function(_scope) {' . $script . '})(window);' . PHP_EOL;
            }
        }

        $jsData .= PHP_EOL . '});' . PHP_EOL . '</script>';
Alia Team
Alia May 6 '14
Ben,  each plugin in Oxwall ( both our and third party plugins) connects .js individually using following method:
OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("base")->getStaticJsUrl() . "JS_FILE_NAME"); 

-addScript method is declared/described  ow_core/html_document.php
- getStaticJsUrl in  ow_core/plugin.php
 
We have purposely designed Oxwall so that .js is connected at the end of the document load thus not interrupting page load process. Unfortunately it is not possible to connect .js asynchronously, since each third party plugin has its own logic and we can't control how third party plugins work. If we include connection of .js at the top of the document one of the plugins might break up at the beginning of the page load, this not allowing rest of the content to be loaded.