
Show HN: Boost mailing list signups with Safe Harbor - saimiam
It&#x27;s written as a blog post but it&#x27;s really a Show HN, as you&#x27;ll see.<p><a href="https:&#x2F;&#x2F;ramachandr.in&#x2F;2018&#x2F;05&#x2F;19&#x2F;the-1-reason-why-no-one-signs-up-for-your-mailing-list&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ramachandr.in&#x2F;2018&#x2F;05&#x2F;19&#x2F;the-1-reason-why-no-one-sig...</a>
======
timvdalen
Repo: [https://github.com/saiscode/safe-
harbor](https://github.com/saiscode/safe-harbor)

Do you have an explanation of the source[1] somewhere? I don't really
understand why you'd need window.performance or why this requires PubNub
(Which also doesn't seem to be loaded as a dependency).

[1]: [https://github.com/saiscode/safe-
harbor/blob/master/assets/j...](https://github.com/saiscode/safe-
harbor/blob/master/assets/js/0.1/safeharbor.js)

~~~
saimiam
I had a couple of constraints which made me go with a tool like Pubnub.

1\. I wanted to release this to the public.

2\. I wanted to have the option of adding support for future socialmedia
referrers without releasing new code.

To solve for 2, I chose to create a central server which pushes out up-to-date
styling instructions on request. The alternative would have been to create a
static css file which runs into issues of caching.

To solve for 1, I chose messaging (PubNub) instead of http to (a) avoid
dealing with CORS because I wasn't sure I'd get it right because my infra is
selfhosted (b) learn and use messaging in a live app.

> window.performance

That flag is to check if a page is being reloaded or not. Since the referrer
http header (from where javascript presumably gets its value) persists across
reloads, to keep track of true referrals vs reloads, I check for the value of
this flag.

