Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
How do I use twitter-text in a browser

I want to count tweet length. Twitter makes this very very hard.

They have this repo: https://github.com/twitter/twitter-text which contains this folder: https://github.com/twitter/twitter-text/tree/master/js which supposedly supports javascript.

When I try to use the script from a cdn like this: https://www.jsdelivr.com/package/npm/twitter-text

it says require is not defined

I don't understand what I'm supposed to do. Why is it using require if it's for javascript?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Install Browserify
  2. Download the latest twitter-text script from this folder: https://github.com/twitter/twitter-text/tree/master/js/pkg
  3. Create index.js with the contents: window.twitter = require('./twitter-text-3.1.0.min.js');
  4. Run browserify index.js -o twitter-text-js.js

The output file can now be run in browser and accessed with the global twitter.

(or just download the prepackaged version here: https://gist.github.com/skeddles/3841236279efebf053dfa39dfdbae2c2#file-twitter-text-js-js)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!