Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
<h2>Please Note: facebook login will not work in codepen as coded.. Copy code into your own document</h2>
  Below we include the Login Button social plugin. This button uses
  the JavaScript SDK to present a graphical Login button that triggers
  the FB.login() function when clicked.
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">

<div id="status">





                // This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {

	// The response object is returned with a status field that lets the app 	know 		the current login status of the person.
  if (response.status === 'connected') {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Successful login for: ' +;
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' + + '!';
  } else if (response.status === 'not_authorized') {
    // The person is logged into Facebook, but not your app.
    document.getElementById('status').innerHTML = 'Please log ' + 'into this app.';
  } else {
    // The person is not logged into Facebook, so we're not sure if they are logged into this app or not.
    document.getElementById('status').innerHTML = 'Please log ' + 'into Facebook.';


// This function is called when someone finishes with the Login Button.
function checkLoginState() {
  FB.getLoginStatus(function(response) {

window.fbAsyncInit = function() {
    appId : '{your-app-id}',
    cookie : true, // enable cookies to allow the server to access the session
    xfbml : true, // parse social plugins on this page
    version : 'v2.1' // use version 2.1

  // Now that we've initialized the JavaScript SDK, we call FB.getLoginStatus(). 
  // This function gets the state of the person visiting this page.
  FB.getLoginStatus(function(response) {

// Load the SDK asynchronously
(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); = id;
    js.src = "//";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));