I think you're beating yourself up too much. A lot of good programmers feel the same way. [1][2][3] If you haven't done something before, it's going to take longer[4]. Also, spending more time initially isn't bad, if it will save you time in the future.
Part of the reason, you might feel that you're lagging, is that the landscape changes so fast. In another thread, someone pointed out the most productive programmers use a stable set of tools and know them inside out. [5] If you have to keep learning new libraries, this will slow down your productivity. Also, contra to what another poster said, taking notes is a good thing. I frequently come across situations where I feel I've done something, so I look back at my notes or git commits. If I have to make all the same mistakes again, it will take 3-4x as long.
1 - http://www.stilldrinking.org/programming-sucks
2 - https://the-pastry-box-project.net/ed-finkler/2014-july-6
3 - http://www.marco.org/2014/07/11/developers-dystopian-future