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

Fixes Mage.Cookies poor performance #9835

Merged

Conversation

wujashek
Copy link
Contributor

@wujashek wujashek commented Jun 2, 2017

While reviewing performance of Magento 1 and Magento 2 websites I was surprised by the time of Mage.Cookies.get calls execution being around 5-10 ms based on number of cookies stored.

This is how it looks on Land Rover website:

cookies-time-on-magento2

What I've found is that the Cookies class uses document.cookie property in extremely not effective way.

Document.cookie call is not just a string property retrieving -
Quote from w3c documentation on document.cookie

The document.cookie property looks like a normal text string. But it is not.

Single call can take from 0,03 to 10 milliseconds on various browsers/devices.

Simple test to reproduce in different browsers/devices : https://jsfiddle.net/rtxee657/1/.

Description

This pull request reduce the time for a Mage.Cookies.get call around 10 times without any side effects, and that gives average Magento 2 based website 1-2% faster page load.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

…ll is not just a string property retrieving - single call can take from 0,03 to 10 milliseconds on various browsers/devices
@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jun 2, 2017

CLA assistant check
All committers have signed the CLA.

@ishakhsuvarov ishakhsuvarov self-assigned this Jun 2, 2017
@ishakhsuvarov ishakhsuvarov added this to the June 2017 milestone Jun 2, 2017
@magento-team magento-team merged commit c43ecce into magento:develop Jun 6, 2017
@magento-team
Copy link
Contributor

@wujashek thank you for your contribution. Your Pull Request has been successfully merged

@wujashek wujashek deleted the mage-cookies-performance-fix branch June 7, 2017 08:04
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.

5 participants