Giter VIP home page Giter VIP logo

eleventy-plugin-inline-tweet's Introduction

eleventy-plugin-inline-tweet

This plugin will transform a text anywhere in your content that looks like:

inlineTweet:https://twitter.com/code_conf/status/651724049463312384

Into the inlined HTML of the tweet, with no external JavaScript needed, with styles inlined and smaller images also inlined. Only large images will not be inlined.

Example of inlined tweet

image

You can also see it in use at the bottom of my Danish page about my speaking engagements at itforedrag.dk. The code for that page is availabel on Github foredrag

Why

Why would you want to inline the html of the tweet, instead of just using the embed functionality on twitter? By inlining the html of the tweet:

  1. You are removing external dependency on the twitter javascript. Using an external JavaScript both slows your page down and has security implications.
  2. It becomes possible to implement an effective lazyload of images
  3. You eliminate the page jumping up and down during hot reload development cycles, where the twitter javascript otherwise would be fetching the inlineded tweet again and again as you hot reload the page ever time you make a change.

Disadvantages

There are some disadvantages to inlinedint the html of tweets

  1. The like counter does not update automatically anymore. You will need to delete the cache at ./inlineTweet.json and rebuild the page to get updated counters.
  2. If twitter changes the layout of inlineded tweets to some kind of better version, you will still be on the version from when you inlineded the tweet.

Installation

Available on npm.

npm install eleventy-plugin-inline-tweet

Open up your Eleventy config file (probably .eleventy.js) and use addPlugin:

const inlineTweetPlugin = require("eleventy-plugin-inline-tweet");

module.exports = function(eleventyConfig) {
  eleventyConfig.addPlugin(inlineTweetPlugin);
};

Read more about Eleventy plugins.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.