{"id":29275,"date":"2017-02-20T20:01:47","date_gmt":"2017-02-20T12:01:47","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=29275"},"modified":"2022-07-13T19:41:58","modified_gmt":"2022-07-13T11:41:58","slug":"reframejs","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/reframejs\/","title":{"rendered":"Make All Embedded Content Responsive with Reframe.js"},"content":{"rendered":"<p>The trickiest part about <strong>embedding videos<\/strong> is getting the width & height correct. These numbers <strong>define the aspect ratio<\/strong> and when they\u2019re off you\u2019ll <strong>get a wonky video player<\/strong>.<\/p>\n<p>This is <strong>true for all embedded elements<\/strong> such as iframes and social media widgets. And these things can be even trickier with responsive design because they\u2019re usually <strong>not responsive elements<\/strong>.<\/p>\n<p>But with <strong><a target=\"_blank\" href=\"https:\/\/dollarshaveclub.github.io\/reframe.js\/\" rel=\"noopener\">Reframe.js<\/a><\/strong>, you can make <strong>any element responsive for any aspect ratio<\/strong>.<\/p>\n<figure><a target=\"_blank\" href=\"https:\/\/dollarshaveclub.github.io\/reframe.js\/\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/reframejs\/01-reframe-embedded.jpg\" alt=\"reframejs homepage\" width=\"938\" height=\"796\"><\/a><\/figure>\n<p class=\"recommended_top\">\n\t\t\t\t\t<strong>Read Also:<\/strong>\u00a0\n\t\t\t\t\t<a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/rwd-tools\/\">50 Useful Responsive Web Design Tools for Web Designers<\/a>\n\t\t\t\t<\/p>\n<p>This is perhaps one of the simplest yet most valuable JS plugins on the web. It was actually <strong>created by Dollar Shave Club<\/strong> which surprisingly has its own <a target=\"_blank\" href=\"https:\/\/github.com\/dollarshaveclub\" rel=\"noopener\">GitHub page<\/a>.<\/p>\n<p>Reframe is <strong>one of their free plugins<\/strong> built for developers who want a simpler way of <strong>handling responsive embedded content<\/strong>.<\/p>\n<p>The obvious culprit is embedded video from sites such as YouTube and Vimeo. It\u2019s notoriously <strong>difficult to make these elements responsive<\/strong> without <a target=\"_blank\" href=\"https:\/\/css-tricks.com\/fluid-width-youtube-videos\/\" rel=\"noopener\">CSS hacks<\/a>.<\/p>\n<p>With Reframe.js, you just <strong>select<\/strong> whatever element you want to target and <strong>reframe it<\/strong> using the <code>reframe()<\/code> function.<\/p>\n<p>Start by adding the Reframe.js plugin to your web page. You can <strong>download a copy<\/strong> <a target=\"_blank\" href=\"https:\/\/github.com\/dollarshaveclub\/reframe.js\" rel=\"noopener\">from GitHub<\/a>, and it\u2019s only 1KB minified.<\/p>\n<p>Then, you just <strong>pass the function a selector<\/strong> for whatever elements you want to reframe. <strong>Load the page<\/strong> and boom! You should be all set.<\/p>\n<p>For example, let\u2019s say you have a few videos embedded on your site. You can <strong>add the class <code>.video<\/code> to the embed<\/strong>, and use that as the selector. Reframe <strong>automatically adds a div and class around it<\/strong> to create the responsive style.<\/p>\n<p>So your <strong>JavaScript code<\/strong> would look like this:<\/p>\n<pre>reframe('.video');<\/pre>\n<p>Pretty simple right?<\/p>\n<p>This code targets all elements with the class <code>.video<\/code> and <strong>makes them responsive<\/strong>. No extra hacks, no extra CSS. Granted there\u2019s nothing wrong with using the CSS method but you will need to <strong>manually wrap<\/strong> all embedded videos with the extra class.<\/p>\n<p>Reframe just <strong>saves you that extra step<\/strong> and brings it all through with JavaScript. To <strong>check out a demo<\/strong> and <strong>find some basic code snippets<\/strong>, visit the <a target=\"_blank\" href=\"https:\/\/dollarshaveclub.github.io\/reframe.js\/\" rel=\"noopener\">Reframe.js homepage<\/a>. You can <strong>download a copy of the code<\/strong> straight from the <a target=\"_blank\" href=\"https:\/\/github.com\/dollarshaveclub\/reframe.js\" rel=\"noopener\">GitHub repo<\/a>.<\/p>\n<p class=\"recommended_top\">\n\t\t\t\t\t<strong>Read Also:<\/strong>\u00a0\n\t\t\t\t\t<a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/responsive-web-tutorials\/\">30 Useful Responsive Web Design Tutorials<\/a>\n\t\t\t\t<\/p>","protected":false},"excerpt":{"rendered":"<p>The trickiest part about embedding videos is getting the width &#038; height correct. These numbers define the aspect ratio and when they\u2019re off you\u2019ll get a wonky video player. This is true for all embedded elements such as iframes and social media widgets. And these things can be even trickier with responsive design because they\u2019re&hellip;<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[352],"tags":[3497,4646,2066],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Make All Embedded Content Responsive with Reframe.js - Hongkiat<\/title>\n<meta name=\"description\" content=\"The trickiest part about embedding videos is getting the width &amp; height correct. These numbers define the aspect ratio and when they&#039;re off you&#039;ll get\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/reframejs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Make All Embedded Content Responsive with Reframe.js\" \/>\n<meta property=\"og:description\" content=\"The trickiest part about embedding videos is getting the width &amp; height correct. These numbers define the aspect ratio and when they&#039;re off you&#039;ll get\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/reframejs\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2017-02-20T12:01:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-13T11:41:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/reframejs\/01-reframe-embedded.jpg\" \/>\n<meta name=\"author\" content=\"Jake Rocheleau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jake Rocheleau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/\"},\"author\":{\"name\":\"Jake Rocheleau\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\"},\"headline\":\"Make All Embedded Content Responsive with Reframe.js\",\"datePublished\":\"2017-02-20T12:01:47+00:00\",\"dateModified\":\"2022-07-13T11:41:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/\"},\"wordCount\":370,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/reframejs\\\/01-reframe-embedded.jpg\",\"keywords\":[\"Javascript Library\",\"Mobile Website Design &amp; Dev\",\"Responsive Web Design\"],\"articleSection\":[\"Web Design\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/\",\"name\":\"Make All Embedded Content Responsive with Reframe.js - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/reframejs\\\/01-reframe-embedded.jpg\",\"datePublished\":\"2017-02-20T12:01:47+00:00\",\"dateModified\":\"2022-07-13T11:41:58+00:00\",\"description\":\"The trickiest part about embedding videos is getting the width &amp; height correct. These numbers define the aspect ratio and when they're off you'll get\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/reframejs\\\/01-reframe-embedded.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/reframejs\\\/01-reframe-embedded.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/reframejs\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Make All Embedded Content Responsive with Reframe.js\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\",\"name\":\"Jake Rocheleau\",\"description\":\"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/jake\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Make All Embedded Content Responsive with Reframe.js - Hongkiat","description":"The trickiest part about embedding videos is getting the width &amp; height correct. These numbers define the aspect ratio and when they're off you'll get","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/reframejs\/","og_locale":"en_US","og_type":"article","og_title":"Make All Embedded Content Responsive with Reframe.js","og_description":"The trickiest part about embedding videos is getting the width &amp; height correct. These numbers define the aspect ratio and when they're off you'll get","og_url":"https:\/\/www.hongkiat.com\/blog\/reframejs\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2017-02-20T12:01:47+00:00","article_modified_time":"2022-07-13T11:41:58+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/reframejs\/01-reframe-embedded.jpg","type":"","width":"","height":""}],"author":"Jake Rocheleau","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Jake Rocheleau","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/"},"author":{"name":"Jake Rocheleau","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a"},"headline":"Make All Embedded Content Responsive with Reframe.js","datePublished":"2017-02-20T12:01:47+00:00","dateModified":"2022-07-13T11:41:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/"},"wordCount":370,"commentCount":3,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/reframejs\/01-reframe-embedded.jpg","keywords":["Javascript Library","Mobile Website Design &amp; Dev","Responsive Web Design"],"articleSection":["Web Design"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/reframejs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/","url":"https:\/\/www.hongkiat.com\/blog\/reframejs\/","name":"Make All Embedded Content Responsive with Reframe.js - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/reframejs\/01-reframe-embedded.jpg","datePublished":"2017-02-20T12:01:47+00:00","dateModified":"2022-07-13T11:41:58+00:00","description":"The trickiest part about embedding videos is getting the width &amp; height correct. These numbers define the aspect ratio and when they're off you'll get","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/reframejs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/reframejs\/01-reframe-embedded.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/reframejs\/01-reframe-embedded.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/reframejs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Make All Embedded Content Responsive with Reframe.js"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a","name":"Jake Rocheleau","description":"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/jake\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-7Cb","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/29275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=29275"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/29275\/revisions"}],"predecessor-version":[{"id":60402,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/29275\/revisions\/60402"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=29275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=29275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=29275"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=29275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}