Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make yandex-metrica generated HTML a bit smaller #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tadatuta
Copy link
Member

@tadatuta tadatuta commented Feb 7, 2017

No description provided.

@@ -22,18 +22,16 @@ block('yandex-metrica').replace()(function() {
' var n = d.getElementsByTagName("script")[0],',
' s = d.createElement("script"),',
' f = function () { n.parentNode.insertBefore(s, n); };',
' s.type = "text/javascript";',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text/javascript is default value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, but why Metrica provides this attribute? May be it brings value for using in old browsers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should care for such old browsers.


noScriptContent = {
tag : 'div',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

div is default value

' s.async = true;',
' s.src = "https://mc.yandex.ru/metrika/watch.js";',
'',
' if (w.opera == "[object Opera]") {',
' d.addEventListener("DOMContentLoaded", f, false);',
' } else { f(); }',
'})(document, window, "yandex_metrika_callbacks");'
].join('\n');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should safe ~35 bytes :)

@tadatuta
Copy link
Member Author

tadatuta commented Feb 7, 2017

please squash commits before merge

@remnev
Copy link
Member

remnev commented Feb 8, 2017

I propose to implement it into a modifier. Something like _minified_true

I don't like to get minified script by default. Metrica provides script such our current template does. I'd like to save this behaviour.

@tadatuta
Copy link
Member Author

tadatuta commented Feb 8, 2017

When you apply BEMHTML templates to BEMJSON you get minimized HTML.
Isn't it strange to have all the HTML of a page as one-liner and the only different piece is Metrica snippet?

@remnev
Copy link
Member

remnev commented Feb 9, 2017

Ok, you're right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants