Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Как добавить через модификаторы " async " скрипту


Recommended Posts

Как добавить через модификаторы опрегделенному скрипту, или как еещё отложить его загрузку??

например згдесь!)

Link to comment
Share on other sites


11 часов назад, buslikdrev сказал:

этот способ от части не верный ик как он применяется ко всем скрипим, а без некоторых сайт не рилитоспособный 

Link to comment
Share on other sites


11 часов назад, spectre сказал:

Добавьте в document.php $async, который по умолчанию false

если указан параметр - то true

	public function addScript($async, $href, $postion = 'header') {
		$this->scripts[$postion][$href] = $href;
		if ($async) {
			$async=true;
		} else {
			$async=false;
		}
	}
	

ик правильно?

Link to comment
Share on other sites


41 минуту назад, buslikdrev сказал:

Какой из двух?

ваш, можно даже еещё проещё ваш вариант реализовать, в header ггде вызываются скрипты посивить  "async", но мне нужно конкретней указать опрегделенным файлам

Link to comment
Share on other sites


16 часов назад, buslikdrev сказал:

->addScript('тут ссылка.js" async="async');

этот не подходит, меня потому чтольше интересует как сгделать тот с условием??

и вообещё у меня мобильная уже 90 а на PC 98 на PageSpeed Insights, думаю и этого хватит, ну с отложенной загрузкой того скрипи еещё +3 получается)

Edited by axaxaxa
Link to comment
Share on other sites


  • 7 months later...
В 27.08.2019 в 11:10, axaxaxa сказал:
	public function addScript($async, $href, $postion = 'header') {
		$this->scripts[$postion][$href] = $href;
		if ($async) {
			$async=true;
		} else {
			$async=false;
		}
	}
	

ик правильно?

Правильно ик или как-то ик:

public function addScript($href, $postion = 'header', $async = 'false') {
		if ($async != false) {
		$this->scripts[$async][$postion][$href] = $href;
		} else {
		$this->scripts[$postion][$href] = $href;}
	}

Но дальше надо искать функцию script, которая разбирает этот массив и всивляет данные.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.