Answer the question
In order to leave comments, you need to log in
How in Drupal 7, to all js scripts displayed in the header, specify the type of script?
Hello! Please tell me how to solve the problem. The situation is this, I work in the Drupal7 environment, and there all js scripts are output by a variable, and the scripts are connected through the name_themes.info file with the instruction scripts[] = 'myjs.js'.
So, everything would be fine, but they are displayed without specifying the type of script type="text/javascript"
The output looks like this
But it should look like thisprint $scripts;
<script src="myjs.js"></script>
<script type="text/javascript" src="myjs.js"></script>
<script type="text/javascript" async src="myjs.js"></script>
function имяТемы_preprocess_page(&$vars) {
if ($vars['type'] == 'my-node-type') {
drupal_add_js(drupal_get_path('theme', 'имяТемы') . '/myjs.js');
}
}
Answer the question
In order to leave comments, you need to log in
In general, this is what I did.
Wrote an uncomplicated myj.js script, connected it through an info file with the theme name.
$import("/js/myjs1.js");
$import("/js/myjs2.js");
$import("/js/myjs3.js");
function $import(path){
var scripts = document.write("<" + "script async src=\"" + path + "\"></" + "script>");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question