WordPress Playground – How to Use WordPress in Your Browser

Do you want to use WordPress in your browser for testing purposes?

Meet WordPress Playground, a platform where you can try out open-source WordPress.org in a browser without purchasing a hosting plan first. You can also use it to test plugins and themes without affecting your live WordPress website.

In this article, we will explain what WordPress Playground is and how to use it.

WordPress PlayGround - How to Use WordPress in Your Browser

What Is WordPress Playground and How Does It Work?

WordPress Playground is a temporary, in-browser WordPress instance where you can experiment and learn more about the content management system.

It’s like an online sandbox where you can do all sorts of WordPress development without affecting your real website.

What the WordPress Playground looks like

All you need to do is go to the WordPress Playground website to open it. Then, you can use WordPress as you normally would: install new plugins, try out new themes, add new pages, and so on.

If you refresh the WordPress Playground page, all the customizations will disappear. However, you can also download your WordPress instance and upload it again to WordPress Playground.

How Does WordPress Playground Work?

WordPress Playground runs on some cool technologies that let you use WordPress without the usual web server and database setup:

  1. WebAssembly binary (Wasm): It lets you run PHP code directly in your web browser, making WordPress work without a traditional server. It also makes the platform compatible with all browsers, from Chrome and Edge to Firefox and Safari.
  2. SQLite database: Instead of MySQL, WordPress Playground uses a lighter file-based database system called SQLite, which runs right in your browser.
  3. Service Worker and Worker Threads APIs: These web tools help handle requests and run background JavaScript scripts, making it possible for WordPress Playground to run PHP apps smoothly in your browser.

These technologies also enable developers to integrate WordPress Playground with node.js, Visual Studio Code, and a CLI tool called wp-now.

With these tools, developers can also use WordPress Playground on a development platform for testing or staging purposes.

What Are the Limitations of WordPress Playground?

Despite its benefits, WordPress Playground has several limitations, like:

  • No direct access to the theme and plugin directory You will have to install themes and plugins by manually downloading and uploading them. That said, a network access beta feature aims to solve this problem.
  • Customizations in WordPress Playground are temporary – If you decide not to save the changes in the browser, you will have to be careful not to accidentally refresh the page to avoid losing your progress.
  • iFrame issues are common – If you embed a WordPress Playground instance on your web page, you may expect some problems, from accidental refreshes to iFrame not working.
  • It’s a relatively new feature – Not everything will work properly, so you can expect some hiccups here and there as you explore the environment.

All that being said, the Playground is a relatively new WordPress project. So you can expect the team to release new features and bug fixes to improve the user experience.

Now that you know what WordPress Playground is, let’s see how you can use it. You can use the quick links below to navigate through our tutorial:

How to Use WordPress Playground

To use WordPress Playground, you can directly go to this domain name in your web browser: https://playground.wordpress.net

Once you are on the website, wait a few moments for the Playground to set up. Then, you will see the front end of the website using a default WordPress theme.

If you are using WordPress Playground for testing, then you may want to configure the environment to reflect the WordPress software for your actual website.

To do this, click the menu that says ‘PHP 8.0 WP 6.4 – Storage: None.’

Configuring the WordPress Playground version

The first setting you have to configure is the storage type. There are three options.

‘None’ means all changes will be lost on page refresh. Meanwhile, ‘Browser’ means changes will be stored in the browser but disappear if you close the browser tab or clear your cache.

You can also save the changes on your computer by selecting ‘Device.’ This option will let you select a folder in your computer to store your WordPress Playground files, similar to creating a localhost WordPress site.

Customizing the WordPress Playground settings

The next thing you want to configure is the PHP version.

We recommend making it the same as the PHP version you use for your website. That said, you may not find PHP versions older than 7.0 here.

Available PHP versions in WordPress Playground

Below that, you can optionally enable the ‘Load extensions: libxml, openssl, mbstring, iconv, gd’ and ‘Network access (e.g., for browsing plugins)’ settings.

The first setting will load those specific PHP extensions (libxml, openssl, mbstring, iconv, and gd) to enhance your WordPress Playground. But they are not necessary.

The second setting is called ‘Network access.’ It’s a beta feature and will connect your WordPress Playground to the official plugin directory so that you can install WordPress themes and plugins right from the environment.

WordPress Playground's PHP settings

Finally, you can select a WordPress version for the Playground. You should pick the version you currently use for your WordPress blog or website.

WordPress also makes the ‘WordPress Nightly’ version available. This is the development version of WordPress that includes the latest changes made by the WordPress development team.

You can use this if you are a plugin or theme developer and want to test compatibility with the next WordPress update.

Once you are done configuring these settings, go ahead and click ‘Apply changes.’

Choosing a WordPress software version in WordPress Playground

And that’s all for the settings. Now, you can head to the admin area to start testing out the sandbox.

To open the admin area, hover over the site title menu and click ‘Dashboard.’ Or, you can also go to the Full Site Editor by clicking ‘Edit site.’

Going to the WordPress Playground dashboard or full site editor

How to Install Themes and Plugins in WordPress Playground

There are two ways to install a WordPress plugin or theme in WordPress Playground. One is to go to a plugin or theme page on WordPress.org and click the ‘Download’ button.

This will save the plugin or theme’s zip file to your computer.

Manually downloading the WPForms plugin

Then you can continue with the usual, manual WordPress installation for plugins and themes. You can read our guides for more instructions:

This method also works for testing premium WordPress plugins and premium WordPress themes.

For plugins, simply go to the dashboard of the WordPress Playground and navigate to Plugins » Add New Plugin.

After that, click the ‘Upload Plugin’ button and select ‘Choose File’ to upload the plugin zip file you downloaded earlier. Finally, click ‘Install Now.’

Installing a WordPress plugin in WordPress Playground

As for themes, WordPress will have a default theme installed for you when you first use the Playground.

But if you want to use a new free WordPress theme, you can download it manually from the WordPress theme directory. Then, in the Playground, go to Appearance » Themes and click ‘Add New Theme.’

Adding a new theme in WordPress Playground

On the next screen, click the ‘Upload Theme’ button.

After that, choose the theme file you downloaded earlier and click ‘Install Now.’

Installing a new theme in WordPress Playground

If this process seems a bit tedious, don’t worry. WordPress has been working on a beta feature allowing Playground to connect with the plugin or theme directory. This should be enabled if you choose ‘Network access’ during the setup earlier.

This way, the Playground works just like any typical WordPress dashboard and you can install free themes and plugins without saving them first to your computer.

Another way to install themes and plugins in WordPress dashboard is by using WordPress Playground’s Query API. It works by requiring you to add some query parameters to the WordPress Playground URL.

So, for example, if you want to install and test AIOSEO’s free version in WordPress Playground, then you can go to AIOSEO’s WordPress.org page. After that, take note of the AIOSEO’s URL slug.

Highlighting AIOSEO's URL slug in WordPress.org's plugin directory

Now, on a new browser tab, type in WordPress Playground’s URL with AIOSEO’s slug, like so:

https://playground.wordpress.net/?plugin=all-in-one-seo-pack

When you hit the ‘Enter’ key, WordPress Playground will automatically create a new environment with the AIOSEO plugin installed.

If you want to install the theme, then just replace the plugin parameter with theme, like so:

https://playground.wordpress.net/?theme=astra

You can even combine multiple query parameters if you want to install multiple plugins or themes on top of WordPress core. Just make sure to separate each parameter with the ampersand & sign.

Here’s what the URL will look like if you are installing the AIOSEO and MonsterInsights plugins as well as the Astra theme:

https://playground.wordpress.net/?theme=astra&plugin=all-in-one-seo-pack&plugin=google-analytics-for-wordpress

If you are a Chrome user, you can also install the Open in WordPress Playground extension. With this, whenever you go to a plugin or theme page on WordPress.org, you will see the ‘Playground’ button.

Clicking it will open a new WordPress Playground environment with the plugin or theme installed. It simplifies the query parameter method.

Using the Open in WordPress Playground Chrome extension

How to Export/Import a Site Made With WordPress Playground

Let’s say you’ve played around with WordPress Playground, added some new posts using the Gutenberg editor, and maybe even created an entire website. It would be a waste to just close the tab and lose all of your progress forever.

Luckily, you can export your site from WordPress Playground and save it to your computer. Whenever you open the Playground again, you can always upload that exported zip file to continue where you left off.

To do this, navigate to the top menu of the Playground and click the three-line menu in the top right corner. Then, click ‘Download as .zip.’

Downloading a WordPress Playground file

Your browser will then start downloading the file to your computer.

To upload the file to WordPress Playground, just open the Playground site and click the three-line menu again. After that, click ‘Restore from .zip.’

Restoring a WordPress Playground zip file

A popup will now ask you to choose a file that you exported earlier.

Once you’ve selected the file, just click ‘Import.’

Importing a WordPress Playground zip file

If the file is valid, you will see a popup notifying you that the import was successful and the Playground will be refreshed with the new instance.

Just click ‘OK’ to close the popup.

A popup message saying the WordPress Playground file import was successful

Import/Export WordPress Playground to GitHub

If you have a GitHub account, you can also export and import your site from WordPress Playground. GitHub is a great platform that allows you to track changes to your website, back up your files, and collaborate with other users.

To export a site from WordPress Playground to GitHub, click the three-line menu and select ‘Export Pull Request to GitHub.’

Exporting a WordPress Playground instance as a pull request to GitHub

In the next popup, you will see that WordPress encourages saving your website to your computer as a backup. Once you do that, you can tick the ‘I exported my Playground as zip’ box.

Then, click the ‘Connect to your GitHub account’ button.

Connecting GitHub with WordPress Playground

Next, you must confirm that you are authorizing WordPress Playground to access your repositories.

Just click ‘Authorize adamziel’ to continue.

Authorizing WordPress Playground to have access over your GitHub

At this stage, go ahead and select what type of files you are exporting: plugins, themes, or wp-content directory. If you want to export plugins, themes, media files, widgets, menus, and fonts, then select the last option.

You will also need to specify the GitHub repository’s URL to which you’d like to export the site. Then, click the ‘Next step’ button.

Choosing a GitHub repository to export the WordPress Playground to

Once you’ve done that, you need to choose whether you are creating a new pull request or updating an existing one. For demonstration purposes, we will choose the first option.

After that, enter the path in the repository where the changes should be committed.

You will also need to insert a commit message to specify what changes have been made using the WordPress Playground.

With all that done, click ‘Create Pull Request.’

Creating a new pull request in GitHub for a WordPress Playground instance

If the export is successful, WordPress will show a popup with a link to the new pull request.

Just click the link to see it in action.

Clicking the link to a newly created pull request of the WordPress Playground instance

Now, if you want to import a site from GitHub into WordPress Playground, just click the three-line menu again.

Then, select ‘Import from GitHub.’

Importing a WordPress Playground instance from GitHub

If you are opening a completely new WordPress Playground environment, then you might need to do the whole GitHub Playground authorization process again.

After that, just click the GitHub repository URL you’d like to import from. WordPress provides some examples if you are unsure.

Selecting a GitHub repository to import from in WordPress Playground

Next, you have to specify what files you are importing: themes, plugins, or the entire wp-content directory.

You may also insert the path of the repository that you are importing from. Once done, simply click ‘Import.’

Choosing what type of files to import from GitHub to WordPress Playground

If the import works, you will see a success message popup, confirming that the WordPress Playground will be refreshed with the new instance.

How to Embed WordPress Playground on Your Website

If you are writing a WordPress tutorial, then you will likely include screenshots from the WordPress dashboard to guide users through your instructions. However, sometimes screenshots just don’t accurately illustrate the actions you are describing.

This is where WordPress Playground can come in handy. You can embed it on your page or post, giving users a more interactive reading experience. They can follow along with your instructions using Playground.

First, you need to open the Gutenberg block editor for a page or post. Once there, click the ‘+’ add block button and select the Custom HTML block.

Selecting the Custom HTML block in the block editor

Now, go ahead and copy the code below, and paste it into the HTML block:

<iframe src="https://playground.wordpress.net/"></iframe>

If you want, you can also add some query parameters to this URL as we have shown you earlier.

After that, click ‘Publish’ or ‘Update’ to make the changes live.

Adding the WordPress Playground iFrame code in the block editor

The WordPress Playground may look different depending on your theme.

In our case, it did not look aligned with the blocks above it, and the element itself was too small to interact with.

The WordPress Playground iFrame element looking misaligned with the rest of the blocks

To avoid this, you can use this code instead:

<div class="iframe-container"><iframe src="https://playground.wordpress.net/" style="width: 100%; height: 500px"></iframe></div>

Here, the iFrame tag is wrapped in div tags to make the Playground embed follow the padding and margin of the container.

We also added the style attribute to set the iFrame’s width to 100% of its container, and the height to be 500 pixels tall.

Here’s what it looks like on the front end:

What the WordPress Playground iFrame code looks like on the front end when it's aligned

Frequently Asked Questions About WordPress Playground

Let’s cover some frequently asked questions about WordPress Playground.

Can you use WordPress in your browser?

Yes, WordPress Playground lets you use WordPress directly in your browser. You can build websites and try out themes and plugins before installing them on your live site.

Can I install custom themes and plugins in WordPress Playground?

Yes, you can install custom themes and plugins in WordPress Playground to see if they work in the admin area and are compatible with certain WordPress versions.

Can I upload a site made with WordPress Playground to my hosting account?

Technically, you can export your site from WordPress Playground and import it into your WordPress hosting account. However, since WordPress Playground uses the SQLite database, you may need to convert the database to MySQL for the site to run on a web server.

How do I run WordPress plugins and themes locally?

If you want to run WordPress plugins and themes in a local development environment, then you must create a local WordPress site first. You can read our tutorial on how to build a local WordPress site for step-by-step instructions.

We hope this article has helped you learn what WordPress Playground is and how to use it in your browser. You may also want to check out our article on how to easily create a staging site for WordPress and our list of the best WordPress plugins to clone or duplicate a site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post WordPress Playground – How to Use WordPress in Your Browser first appeared on WPBeginner.

iframe feedback

What if an <iframe> had within it another <iframe> of the exact same source? Inception, as they say. Baptise Crespy does this all-important research in the name of art and science.

Turns out browsers are smart enough to not allow this infinite looping to occur (and likely crash your browser/computer). They strip the content after the 2nd nest. But! If you change the URL of the src to be unique (but still essentially serve the same document), it works. Adding some random colors and animations and things get weird really fast.

Motion warning video:

Direct Link to ArticlePermalink


The post iframe feedback appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

How to Easily Embed iFrame Code in WordPress (3 Methods)

Do you want to embed an iFrame code in a WordPress post or page?

IFrames provide an easy way to embed video or other content to your site without uploading it. Many third-party platforms like YouTube allow users to use iframe to embed content from their website.

In this article, we’ll show you how to easily embed iFrame code in WordPress using multiple methods.

Easily embedding iFrame code in WordPress

What is iFrame?

An iFrame lets you embed videos or other content on your site. This means you can display a video on your site without actually hosting that video.

The iframe is like opening a window on your site to display external content. The actual content is still loaded from the source that you are embedding from.

To add an iframe, you need to add a special HTML code. Don’t worry if that sounds quite technical.

We’re going to show you the easiest way to embed an iFrame in your WordPress blog.

Why Use iFrames?

A key reason to use iFrames is to avoid having to host videos or other resources on your site, which will use up your bandwidth and storage space.

Also, iFrames let you avoid infringing on other people’s copyrighted content. Instead of downloading their video or other content then uploading it to your site, you simply add it to your page using an iFrame.

Another advantage is that if the original content is changed, it will automatically be updated in the iFrame too.

An image of cartoon people adding content to a website

There are also some drawbacks to using iFrames. Not all websites let you put their content into an iFrame. Also, the iFrame may end up too big or small for your page, and you will need to manually adjust it.

Another issue is that HTTPS sites can only use iFrames for content from other HTTPS sites. Similarly, HTTP sites can only use iFrames for content from other HTTP sites.

This is why many platforms like WordPress prefers oEmbed. You can use oEmbed to embed videos as well as some other types of content by simply pasting a URL into your WordPress post. The content will automatically be resized to fit, and it will be the right size even on mobile devices.

Important: WordPress doesn’t support oEmbed for Facebook and Instagram posts. For more on this, check out our full guide on the Facebook / Instagram oEmbed issue and how to fix it.

Another great alternative to iFrames is to use a social feeds plugin. We recommend using Smash Balloon‘s plugins. These let you display content from Facebook, Instagram, Twitter, and YouTube.

Having said that, let’s take a look at three different ways to add iFrames to your site.

1. Use the Source’s Embed Code to Add iFrame in WordPress

Many large sites have an Embed option for their content. This gives you the special iFrame code that you need to add to your site.

On YouTube, you can get this code by going to the video on YouTube, then clicking the Share button below it.

Clicking the Share button for your chosen YouTube video

Next, you will see a popup with several share options. Simply click on the Embed button.

Clicking the Embed button to get the YouTube embed code

Now, YouTube will show you the iFrame code. By default, YouTube will include the player controls. We also recommend that you enable the privacy-enhanced mode.

After that, go ahead and click the Copy button to copy the code.

Copying the embed code for the YouTube video

Now, you can paste that code into any post or page on your site. We’re going to add it to a new page in the block editor.

To create a new page, go to Pages » Add New in your WordPress dashboard.

Then, add an HTML block to your page.

Adding a custom HTML block to WordPress

Now, you need to paste the YouTube iFrame code into this block.

Pasting the YouTube HTML code into the iFrame block

You can then preview or publish your page to see the YouTube video embedded there.

Viewing the embedded video live on your website

Tip: If you’re using the old classic editor, you can still add iFrame code. You need to do so in the Text view.

Adding the YouTube iFrame code in the classic editor

Switching between the visual and text view on the Classic Editor can cause issues with the iFrame code.

2. Using the iFrame WordPress Plugin to Embed an iFrame

This method is useful as it allows you to create an iframe to embed content from any source, even if that source doesn’t provide an embed code.

First, you need to install and activate the iFrame plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, the plugin will start working straight away with no setup needed. Go ahead and edit or create a post or page. Then, add a shortcode block.

Adding a shortcode block in the block editor

After that, you can use this shortcode to enter your iFrame code.

[iframe src="URL goes here"]

Simply replace URL goes here with the URL of the content you want to embed on your site. We are embedding a Google map.

Tip: You may need to use the Embed option to get the direct URL of the content. You need to use just the URL, not the rest of the embed code.

The shortcode to embed a Google map

Next, preview or publish your post. You should see the Google map embedded on your site.

The Google map embedded on the website

You can optionally add parameters to the iFrame shortcode to change how the embedded content displays. For instance, you could set the width and height, and add or remove a scrollbar or border. You can find details on the iFrame plugin’s page.

Tip: If you’re using the Classic editor, you can simply paste the shortcode into your post or page. You don’t need to switch to the Text view.

Adding the shortcode in the classic editor

3. Manually Creating the iFrame Code and Embedding in WordPress

If you prefer not to use an iFrame plugin, then you can create the iFrame code manually. To do this, you need to add an HTML block in the WordPress content editor.

Adding a custom HTML block

First, you need to paste this code into your HTML block.

<iframe src="URL goes here"></iframe>

Simply replace “URL goes here” with the direct URL for the content that you want to embed. You only need the URL itself.

Here, we’re embedding a map from Google.

Entering the iFrame code for the Google map

You can add extra parameters to the HTML tag. For instance, you could set the width and height of your iFrame. The code below means your embedded content will display 600 pixels wide and 300 pixels high.

<iframe src="URL goes here" width="600" height="300"></iframe>

This is useful if you need to restrict the embedded content to a smaller space.

The Google map on the site with a set height and width

We hope this article helped you learn how to easily embed iFrame code in WordPress. You may also want to check out our ultimate guide on how to speed up your WordPress site, and our comparison of the best keyword research tools for improving your SEO rankings.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Easily Embed iFrame Code in WordPress (3 Methods) appeared first on WPBeginner.

lite-youtube-embed

A standard copy-and-paste YouTube embed lands on your page as an <iframe> which loads a big ol' pile of other stuff to play that video. But the UX of it is still essentially an image and a play button. Click the play button and the video plays. You can build essentially the same thing with an anchor link wrapping an image!

Not long ago, we covered a very clever "lazy load" technique doing exactly this from Arthur Corenzan that was further improved by Remy Sharp and Adrian Roselli.

Paul Irish has tackled it as well with a <lite-youtube> web component:

Provide videos with a supercharged focus on visual performance. This custom element renders just like the real thing but approximately 224X faster.

In the source code, Paul dug up some other prior attempts as well, like this jQuery plugin and a more generic script for lazy loading any iframe.

Direct Link to ArticlePermalink

The post lite-youtube-embed appeared first on CSS-Tricks.

Lazy load embedded YouTube videos

This is a very clever idea via Arthur Corenzan. Rather than use the default YouTube embed, which adds a crapload of resources to a page whether the user plays the video or not, use the little tiny placeholder webpage that is just an image you can click that is linked to the YouTube embed.

It still behaves essentially exactly the same: click, play video in place.

The trick is rooted in srcdoc, a feature of <iframe> where you can put the entire contents of an HTML document in the attribute. It's like inline styling but an inline-entire-documenting sort of thing. I've used it in the past when I embedded MailChimp-created newsletters on this site. I'd save the email into the database as a complete HTML document, retrieve it as needed, and chuck it into an <iframe> with srcdoc.

Arthur credits Remy for a tweak to get it working in IE 11 and Adrian for some accessibility tweaks.

I also agree with Hugh in the comments of that post. Now that native lazy loading has dropped in Chrome (see our coverage) we might as well slap loading="lazy" on there too, as that will mean no requests at all if it renders out of viewport.

I'll embed a demo here too:

See the Pen
Lazy Loaded YouTube Video
by Chris Coyier (@chriscoyier)
on CodePen.

Direct Link to ArticlePermalink

The post Lazy load embedded YouTube videos appeared first on CSS-Tricks.