Pergunta

I'm using wordpress and i have many plugins which using javascript file.

I want to add "defer" tag in all javascript including inline script.

I don't wanna edit each file and add it manually.

So is there any code available like htaccess or some other code to add that tag automatically?

Thanks

Foi útil?

Solução

I assume you are using Apache since you reference .htaccess. It's probably a bad idea, but maybe you can use mod_ext_filter. There is an example there titled "Using sed to replace text in the response." I guess you could try and replace <script with <script defer.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top