{"action":"created","issue":{"url":"https://api.github.com/repos/justcoded/just-responsive-images/issues/30","repository_url":"https://api.github.com/repos/justcoded/just-responsive-images","labels_url":"https://api.github.com/repos/justcoded/just-responsive-images/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/justcoded/just-responsive-images/issues/30/comments","events_url":"https://api.github.com/repos/justcoded/just-responsive-images/issues/30/events","html_url":"https://github.com/justcoded/just-responsive-images/issues/30","id":388353679,"node_id":"MDU6SXNzdWUzODgzNTM2Nzk=","number":30,"title":"Performance issues when using rwd_attachment_background","user":{"login":"mvpspl619","id":5555261,"node_id":"MDQ6VXNlcjU1NTUyNjE=","avatar_url":"https://avatars2.githubusercontent.com/u/5555261?v=4","gravatar_id":"","url":"https://api.github.com/users/mvpspl619","html_url":"https://github.com/mvpspl619","followers_url":"https://api.github.com/users/mvpspl619/followers","following_url":"https://api.github.com/users/mvpspl619/following{/other_user}","gists_url":"https://api.github.com/users/mvpspl619/gists{/gist_id}","starred_url":"https://api.github.com/users/mvpspl619/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvpspl619/subscriptions","organizations_url":"https://api.github.com/users/mvpspl619/orgs","repos_url":"https://api.github.com/users/mvpspl619/repos","events_url":"https://api.github.com/users/mvpspl619/events{/privacy}","received_events_url":"https://api.github.com/users/mvpspl619/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-06T19:05:16Z","updated_at":"2018-12-06T19:10:30Z","closed_at":null,"author_association":"NONE","body":"The function `rwd_attachment_background` takes more than 2s to load for some images and it's faster for some images. \r\n\r\nWe're using a timing function to calculate the performance, the setup looks like this:\r\n```\r\nfunction rwd_attachment_background( $selector, $attachment = null, $size = 'thumbnail' ) {\r\n\t$jri_time_start = microtime(true);\r\n\t$rwd_image = new RwdImage( $attachment );\r\n\t$jri_time_end = microtime(true);\r\n\r\n\t$class_exec_time = $jri_time_end - $jri_time_start;\r\n\r\n\t//execution time of the script\r\n\t$jri_time_start_2 = microtime(true);\r\n\techo $rwd_image->background( $selector, $size );\r\n\t$jri_time_end_2 = microtime(true);\r\n\t$bg_exec_time = $jri_time_end_2 - $jri_time_start_2;\r\n\techo '<b>'.$selector.' Class Time:</b> '.$class_exec_time.' Secs, <b>Bg Time:</b> '.$bg_exec_time.' Secs';\r\n}\r\n```\r\n\r\nThe responses are over 2s for some images. \r\nFollowing are some examples:\r\n- `.hero-banner-7 Class Time: 0.00051212310791016 Secs, Bg Time: 2.0852770805359 Secs`\r\n- `.hero-banner-9 Class Time: 0.00041794776916504 Secs, Bg Time: 2.2101640701294 Secs`\r\n- `.hero-banner-11 Class Time: 1.0967254638672E-5 Secs, Bg Time: 0.39931702613831 Secs`\r\n- `.services-388 Class Time: 0.00033903121948242 Secs, Bg Time: 0.31205105781555 Secs`\r\n\r\nCan you help us figure out why some images are taking a long time to load while some load faster even when using the same image size?"},"comment":{"url":"https://api.github.com/repos/justcoded/just-responsive-images/issues/comments/444992288","html_url":"https://github.com/justcoded/just-responsive-images/issues/30#issuecomment-444992288","issue_url":"https://api.github.com/repos/justcoded/just-responsive-images/issues/30","id":444992288,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDk5MjI4OA==","user":{"login":"mvpspl619","id":5555261,"node_id":"MDQ6VXNlcjU1NTUyNjE=","avatar_url":"https://avatars2.githubusercontent.com/u/5555261?v=4","gravatar_id":"","url":"https://api.github.com/users/mvpspl619","html_url":"https://github.com/mvpspl619","followers_url":"https://api.github.com/users/mvpspl619/followers","following_url":"https://api.github.com/users/mvpspl619/following{/other_user}","gists_url":"https://api.github.com/users/mvpspl619/gists{/gist_id}","starred_url":"https://api.github.com/users/mvpspl619/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvpspl619/subscriptions","organizations_url":"https://api.github.com/users/mvpspl619/orgs","repos_url":"https://api.github.com/users/mvpspl619/repos","events_url":"https://api.github.com/users/mvpspl619/events{/privacy}","received_events_url":"https://api.github.com/users/mvpspl619/received_events","type":"User","site_admin":false},"created_at":"2018-12-06T19:10:30Z","updated_at":"2018-12-06T19:10:30Z","author_association":"NONE","body":"@aprokopenko Here you go. \r\n\r\n```\r\n'hero-banner 2x' => array(\r\n        'desktop' => array(\r\n            array(2304, 1116, true),\r\n            'picture' => '<source srcset=\"{src}\"  media=\"(min-width: 1441px)\">',\r\n            'bg' => '@media (min-width:1441px)',\r\n            'bg_retina' => '@media (min-width:1441px) and {dpr}, (min-width:1441px) and {min_res}',\r\n            'srcset' => '{w}w',\r\n            'sizes' => '(min-width: 1441px) {w}px',\r\n        ),\r\n        'laptop' => array(\r\n            array(1728, 936, true),\r\n            'picture' => '<source srcset=\"{src}\" media=\"(min-width: 769px)\">',\r\n            'bg' => '@media (min-width: 769px)',\r\n            'bg_retina' => '@media (min-width: 769px) and {dpr}, (min-width: 769px) and {min_res}',\r\n            'srcset' => '{w}w',\r\n            'sizes' => '(min-width: 769px) {w}px',\r\n        ),\r\n        'tablet' => array(\r\n            array(922, 936, true),\r\n            'picture' => '<source srcset=\"{src}\" media=\"(min-width: 361px)\">',\r\n            'bg' => '@media (min-width: 361px)',\r\n            'bg_retina' => '@media (min-width: 361px) and {dpr}, (min-width: 361px) and {min_res}',\r\n            'srcset' => '{w}w',\r\n            'sizes' => '(min-width: 361px) {w}px',\r\n        ),\r\n        'mobile' => array(\r\n            array(432, 432, true),\r\n            'picture' => '<img src=\"{single-src}\" srcset=\"{src}\" alt=\"{alt}\">',\r\n            'bg' => '',\r\n            'bg_retina' => '@media {dpr}, {min_res}',\r\n            'srcset' => '{w}w',\r\n            'sizes' => '{w}px',\r\n        )\r\n    )\r\n```\r\n\r\nIt happens on each page load."}}
{"actor":{"display_login":"mvpspl619"}}