https://github.com/stefanbohacek/alternative-twitter-embeds
Embed tweets on your site without compromising your users' privacy and your site's performance.
https://github.com/stefanbohacek/alternative-twitter-embeds
nodejs ownyourdata twitter twitter-api
Last synced: about 1 year ago
JSON representation
Embed tweets on your site without compromising your users' privacy and your site's performance.
- Host: GitHub
- URL: https://github.com/stefanbohacek/alternative-twitter-embeds
- Owner: stefanbohacek
- License: mit
- Created: 2021-03-31T22:01:13.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-01-13T18:34:38.000Z (over 3 years ago)
- Last Synced: 2025-03-26T21:11:45.415Z (over 1 year ago)
- Topics: nodejs, ownyourdata, twitter, twitter-api
- Language: SCSS
- Homepage: https://alternative-twitter-embeds.glitch.me/
- Size: 390 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Alternative Tweet Embeds
Embed tweets without compromising your users' privacy and your site's performance.
Learn more on [stefanbohacek.com](https://stefanbohacek.com/project/tweet-embeds-wordpress-plugin/). Also available as a [WordPress plugin](https://wordpress.org/plugins/tembeds/).
## How to use
Remix this project and update `.env` file with your own Twitter API keys. (See instructions inside that file.)
You can then open your project to see how to add necessary `style` and `script` tags to your page.


Be sure to remove any `script` tags from the [embed code that Twitter gives you](https://help.twitter.com/en/using-twitter/how-to-embed-a-tweet).
```html
```
If you're using Bootstrap v4 on your site, you can load an alternative slimmed down stylesheet.
```html
```
## Performance improvements
See a comparison of the PageSpeed performance test results between [this project's page](https://alternative-twitter-embeds.glitch.me/) and the [test page](https://alternative-twitter-embeds.glitch.me/test.html).

- [Project page](https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Falternative-twitter-embeds.glitch.me%2Ftest.html&tab=desktop)
- [Test page](https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Falternative-twitter-embeds.glitch.me%2F&tab=desktop) ([view test page](https://alternative-twitter-embeds.glitch.me/test.html))
## Questions and tips
Need help or want to share feedback or suggestions? Feel free to reach out [via email](mailto:stefan@stefanbohacek.com) or [on Twitter](https://twitter.com/stefanbohacek)!
### I want to run some code after all tweets are processed
Use the `tembeds_tweets_processed` event.
```js
document.addEventListener('tembeds_tweets_processed', () => {
const tweets = document.querySelectorAll('.twitter-tweet');
console.log('tweets are ready', tweets);
});
```
Here's an example using jQuery.
```js
$(document).on('tembeds_tweets_processed', () => {
const $tweets = $('.twitter-tweet');
console.log('tweets are ready', $tweets);
});
```
### How do I prevent others from using my app?
Use the `ALLOWED_URLS` variable inside your `.env` file.
```
ALLOWED_URLS='alternative-twitter-embeds.glitch.me'
```
You can list multiple domains, separated by a comma.